<?php
/* 	These code was generated using phpCIGen v 0.1.b (24/06/2009)
	#zaqi 		zaqi.smart@gmail.com,http://zenzaqi.blogspot.com,
	#CV. Trust Solution, jl. Saronojiwo 19 Surabaya, http://www.ts.co.id

	+ Module  		: m_shift View
	+ Description	: For record view
	+ Filename 		: v_m_shift.php
 	+ creator  		: 
 	+ Created on 31/May/2011 09:41:28

*/
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
</head>
<style type="text/css">
        p { width:650px; }
		.search-item {
			font:normal 11px tahoma, arial, helvetica, sans-serif;
			padding:3px 10px 3px 10px;
			border:1px solid #fff;
			border-bottom:1px solid #eeeeee;
			white-space:normal;
			color:#555;
		}
		.search-item h3 {
			display:block;
			font:inherit;
			font-weight:bold;
			color:#222;
		}

		.search-item h3 span {
			float: right;
			font-weight:normal;
			margin:0 0 5px 5px;
			width:100px;
			display:block;
			clear:none;
		}
    </style>
<script>
/**
 * 
 */
/* declare function */
var lap_cat_pers_bbm_tableColumnModel;
var lap_cat_pers_bbm_tableListGrid;
var t_lap_cat_pers_bbm_filterForm;
/* decalare KONSTANSTA */
var FAILED_SAVE="Data gagal disimpan";
var FAILED_CONNECTION="Koneksi database server gagal, hubungi Administrator";
var FAILED_VALID_FORM="Data input belum sempurna";
var FAILED_DELETE_SELECTED="Tidak ada data yang terpilih untuk dihapus";
var FAILED_UPDATE_SELECTED="Tidak ada data yang terpilih untuk diupdate";
var FAILED_DELETE="Data gagal dihapus";
var FAILED_EXCEL="Data gagal diexport ke Excel";
var FAILED_PRINT="Data gagal dicetak";
var FAILED_PERMISSION="Anda tidak mempunyai akses untuk aksi ini";
var CONFIRM_DELETE="Apakah Anda yakin menghapus rekod ini?";
var CONFIRM_MULTI_DELETE="Apakah Anda yakin menghapus rekod-rekod ini?";
var SUCCESS_SAVE="Data sukses disimpan";
var TITLE_LIST="Daftar Data";
var TITLE_FORM="Form Input/Update";
var TITLE_FORM_SEARCH="Pencarian Lanjut";
var BTN_SAVE="Simpan";
var BTN_SEARCH="Cari";
var BTN_CANCEL="Reset";
var BTN_SUMMARY="Rekap";
var BTN_ADD_TITLE="Tambah";
var BTN_EDIT_TITLE="Ubah";
var BTN_DELETE_TITLE="Hapus";
var BTN_SEARCH_TITLE="Pencarian";
var BTN_PRINT_TITLE="Cetak";
var BTN_EXCEL_TITLE="Export Excel";
var BTN_REFRESH_TITLE="Refresh Data";
var BTN_ADD_TOOLTIP="Tambah Data Baru";
var BTN_EDIT_TOOLTIP="Ubah Data";
var BTN_DELETE_TOOLTIP="Hapus Data";
var BTN_SEARCH_TOOLTIP="Pencarian Lanjut Data";
var BTN_SIMPLE_SEARCH_TOOLTIP="Pencarian Sederhana";
var BTN_PRINT_TOOLTIP="Cetak Data (html)";
var BTN_EXCEL_TOOLTIP="Export ke bentuk Excel";
var BTN_REFERSH_TOOLTIP="Refresh Data";
var INFO_REQUIRED="Wajib diisi";
var PERMISSION="RCUD";
//declare konstant
var post2db = 'CREATE';
var msg = 'created';
var pageS=15;
var r_tanggal=new Date().format('m');
var r_tahun=new Date().format('Y');

/* on ready fuction */
Ext.onReady(function(){
	Ext.QuickTips.init();	/* Initiate quick tips icon */


	/* Function for Retrieve DataStore */
	var lap_cat_pers_bbm_tableDataStore = new Ext.data.Store({
		id: 'lap_cat_pers_bbm_tableDataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_laporan_cat_pers_bbm&m=get_list',
			method: 'POST'
		}),
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total'
		},[
			{name: 'tanggal', type: 'date', dateFormat: 'Y-m-d', mapping: 'shift_date'},
			{name: 'shift', type: 'string', mapping: 'shift_id'},
			{name: 'stok_awal', type: 'float', mapping: 'stok_awal'},
			{name: 'no_pol', type: 'string', mapping: 'bbmrec_nopol'},
			{name: 'no_do', type: 'string', mapping: 'bbmrec_do'},
			{name: 'volume_penerimaan_sebelum', type: 'float', mapping: 'bbmrec_volume_a'},
			{name: 'volume_penerimaan', type: 'float', mapping: 'bbmrec_volume'},
			{name: 'volume_penerimaan_aktual', type: 'float', mapping: 'bbmrec_volume_actual'},
			{name: 'volume_penerimaan_selisih', type: 'float', mapping: 'bbmrec_volume_diff'},
			{name: 'volume_dispenser', type: 'float', mapping: 'pengeluaran_dispenser'},
			{name: 'volume_akhir', type: 'float', mapping: 'stok_akhir_teoritis'},
			{name: 'volume_akhir_aktual', type: 'float', mapping: 'stok_akhir_aktual'},
			{name: 'volume_akhir_selisih', type: 'float', mapping: 'stok_akhir_selisih'}
		]),
		sortInfo:{field: 'tanggal', direction: "ASC"}
	});

	var warehouseDataStore = new Ext.data.Store({
		id: 'warehouseDataStore',
		proxy: new Ext.data.HttpProxy({
			url: 'index.php?c=c_public_function&m=get_warehouse_bbm',
			method: 'POST'
		}),
		baseParams: {start:0, limit: pageS},
		reader: new Ext.data.JsonReader({
			root: 'results',
			totalProperty: 'total'
		},[
			{name: 'warehouse_id', type: 'int', mapping: 'warehouse_id'},
			{name: 'warehouse_name', type: 'string', mapping: 'warehouse_name'}
			]),
		sortInfo:{field: 'warehouse_id', direction: "DESC"}
	});
	/* End of Function */
	
	/* Field for search */
	var lap_cat_pers_bbm_tgl_awalField= new Ext.form.DateField({
		id: 'lap_cat_pers_bbm_tgl_awalField',
		allowBlank: false,
		bodyStyle:'padding:5px',
		format: 'Y-m-d',
		allowBlank: false,
		editable: true,
		width: 90,
		value: new Date()
	});
	
	var lap_cat_pers_bbm_tgl_akhirField= new Ext.form.DateField({
		id: 'lap_cat_pers_bbm_tgl_akhirField',
		allowBlank: false,
		bodyStyle:'padding:5px',
		format: 'Y-m-d',
		allowBlank: false,
		editable: true,
		width: 90,
		value: new Date()
	});
	
	var t_bill_lap_customerField= new Ext.form.ComboBox({
 		id: 't_bill_lap_customerField',
 		store: customerDataStore,
 		mode: 'remote',
 		displayField:'customer_name',
 		valueField: 'customer_id',
		editable: false,
 		anchor: '95%',
 		allowBlank: false,
		emptyText: 'Pilih Klien...',
 		triggerAction: 'all'
 	});
	
	/* End of Function */
	
	function is_lap_cat_pers_bbm_form_valid(){
		return (lap_cat_pers_bbm_tgl_awalField.isValid() &&
			lap_cat_pers_bbm_tgl_akhirField.isValid() &&
			lap_cat_pers_bbm_warehouseField.isValid());
	}
	/* END Event Handler */
	
	
	/* START GridPanel For Table by Pump */
	lap_cat_pers_bbm_tableColumnModel = new Ext.grid.ColumnModel([
 		{
 			header: 'Tanggal',
 			dataIndex: 'tanggal',
 			width: 75,
 			sortable: false,
 			renderer: Ext.util.Format.dateRenderer('d-m-Y')
 		},
		{
 			header: 'Shift',
 			dataIndex: 'shift',
 			width: 50,
 			sortable: false
 		},
 		{
 			header: '<center>Stok <br/>Awal (L)</center>',
 			dataIndex: 'stok_awal',
 			width: 50,
 			sortable: false,
			align: 'right',
			renderer: function(val){
				return '<span>'+Ext.util.Format.number(val,'0,000.00')+'</span>';
			}
 		},
 		{
 			header: '<center>No. Pol<br/>Mobil Tangki</center>',
 			dataIndex: 'no_pol',
 			width: 75,
 			sortable: false
		},
		{
 			header: '<center>No. PNBP</center>',
 			dataIndex: 'no_do',
 			width: 75,
 			sortable: false
		},
		{
 			header: '<center>Volume Sebelum<br/>Penerimaan (L)</center>',
 			dataIndex: 'volume_penerimaan_sebelum',
 			width: 75,
 			sortable: false,
			align: 'right',
			renderer: function(val){
				return '<span>'+Ext.util.Format.number(val,'0,000.00')+'</span>';
			}
 		},
		{
 			header: '<center>Volume <br/>Penerimaan PNBP (L)</center>',
 			dataIndex: 'volume_penerimaan',
 			width: 75,
 			sortable: false,
			align: 'right',
			renderer: function(val){
				return '<span>'+Ext.util.Format.number(val,'0,000.00')+'</span>';
			}
 		},
		{
 			header: '<center>Volume <br/>Penerimaan Aktual (L)</center>',
 			dataIndex: 'volume_penerimaan_aktual',
 			width: 75,
 			sortable: false,
			align: 'right',
			renderer: function(val){
				return '<span>'+Ext.util.Format.number(val,'0,000.00')+'</span>';
			}
 		},
		{
 			header: '<center>Selisih<br/>Volume (L) [R/L]</center>',
 			dataIndex: 'volume_penerimaan_selisih',
 			width: 75,
 			sortable: false,
			align: 'right',
			renderer: function(val){
				return '<span>'+Ext.util.Format.number(val,'0,000.00')+'</span>';
			}
 		},
		{
 			header: '<center>Pengeluaran<br/>Dispenser (L)</center>',
 			dataIndex: 'volume_dispenser',
 			width: 75,
 			sortable: false,
			align: 'right',
			renderer: function(val){
				return '<span>'+Ext.util.Format.number(val,'0,000.00')+'</span>';
			}
 		},
		{
 			header: '<center>Stok Akhir<br/>Teoritis (L)</center>',
 			dataIndex: 'volume_akhir',
 			width: 75,
 			sortable: false,
			align: 'right',
			renderer: function(val){
				return '<span>'+Ext.util.Format.number(val,'0,000.00')+'</span>';
			}
 		},
		{
 			header: '<center>Stok Akhir<br/>Aktual (L)</center>',
 			dataIndex: 'volume_akhir_aktual',
 			width: 75,
 			sortable: false,
			align: 'right',
			renderer: function(val){
				return '<span>'+Ext.util.Format.number(val,'0,000.00')+'</span>';
			}
 		},{
 			header: '<center>Selisih Total<br/>Pengeluaran (L)</center>',
 			dataIndex: 'volume_akhir_selisih',
 			width: 75,
 			sortable: false,
			align: 'right',
			renderer: function(val){
				return '<span>'+Ext.util.Format.number(val,'0,000.00')+'</span>';
			}
 		}
 		
	]);
	
	function lap_cat_pers_bbm_search_table(){
		if(is_lap_cat_pers_bbm_form_valid()){	
			lap_cat_pers_bbm_tableDataStore.setBaseParam('tgl_awal', lap_cat_pers_bbm_tgl_awalField.getValue().format('Y-m-d'));
			lap_cat_pers_bbm_tableDataStore.setBaseParam('tgl_akhir', lap_cat_pers_bbm_tgl_akhirField.getValue().format('Y-m-d'));
			lap_cat_pers_bbm_tableDataStore.setBaseParam('warehouse', lap_cat_pers_bbm_warehouseField.getValue());
			lap_cat_pers_bbm_tableDataStore.load();
		}else{
			Ext.MessageBox.show({
				title: 'Warning',
				msg: FAILED_VALID_FORM,
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}
	}
	/* START Event Handler */
	function print_list(){
		if(is_lap_cat_pers_bbm_form_valid()){
			var tgl_awal_field=null;
			var tgl_akhir_field=null;
			var warehouse_field=null;
			
			
			// check if we do have some search data...
			if(lap_cat_pers_bbm_tgl_awalField.getValue()!==""){tgl_awal_field = lap_cat_pers_bbm_tgl_awalField.getValue().format('Y-m-d');}
			if(lap_cat_pers_bbm_tgl_akhirField.getValue()!==null){ tgl_akhir_field = lap_cat_pers_bbm_tgl_akhirField.getValue().format('Y-m-d'); }
			if(lap_cat_pers_bbm_warehouseField.getValue()!==null){ warehouse_field = lap_cat_pers_bbm_warehouseField.getValue(); }
			
	
			Ext.MessageBox.show({
			   msg: 'Sedang memproses data, mohon tunggu...',
			   progressText: 'proses...',
			   width:350,
			   wait:true
			});
	
			Ext.Ajax.request({
			waitMsg: 'Please Wait...',
			timeout: 3600000,
			url: 'index.php?c=c_laporan_cat_pers_bbm&m=print_list',
			params: {
				tgl_awal 	: tgl_awal_field,
				tgl_akhir	: tgl_akhir_field,
				warehouse	: warehouse_field
			},
			success: function(response){
			  	var result=eval(response.responseText);
			  	switch(result){
			  	case 1:
					
					win = window.open('./print/t_laporan_cat_pers_bbm_list.html','laporang_cat_pers_bbm','height=400,width=600,resizable=1,scrollbars=1, menubar=1');
					Ext.MessageBox.hide();
					break;
	
			  	default:
					Ext.MessageBox.show({
						title: 'Warning',
						msg: 'Unable to print the grid!',
						buttons: Ext.MessageBox.OK,
						animEl: 'save',
						icon: Ext.MessageBox.WARNING
					});
					break;
			  	}
			},
			failure: function(response){
			  	var result=response.responseText;
				Ext.MessageBox.show({
				   title: 'Error',
				   msg: 'Koneksi database gagal.',
				   buttons: Ext.MessageBox.OK,
				   animEl: 'database',
				   icon: Ext.MessageBox.ERROR
				});
			}
			});
		}else{
			Ext.MessageBox.show({
				title: 'Warning',
				msg: FAILED_VALID_FORM,
				buttons: Ext.MessageBox.OK,
				animEl: 'save',
				icon: Ext.MessageBox.WARNING
			});
		}
	}
	
	lap_cat_pers_bbm_tableListGrid =  new Ext.grid.GridPanel({
		id: 'lap_cat_pers_bbm_tableListGrid',
		renderTo: 'el_lap_cat_pers_bbm_filter',
		autoHeight: true,
		store: lap_cat_pers_bbm_tableDataStore, // DataStore
		cm: lap_cat_pers_bbm_tableColumnModel, // Nama-nama Columns
		enableColLock:false,
		plain: true,
		selModel: new Ext.grid.RowSelectionModel({singleSelect:false}),
		viewConfig: { forceFit:true },
	  	width: 1280,
		tbar: [{xtype:'label', text: 'Tanggal : '} ,{xtype:'spacer', width: 10} ,lap_cat_pers_bbm_tgl_awalField,{xtype:'spacer', width: 5},
		       {xtype:'label', text: 's/d : '} ,{xtype:'spacer', width: 10} ,lap_cat_pers_bbm_tgl_akhirField,{xtype:'spacer', width: 5},
		       {xtype:'label', text: 'Pilih Tangki : '} ,{xtype:'spacer', width: 10} ,lap_cat_pers_bbm_warehouseField,{xtype:'spacer', width: 5}
			,'-' ,{
				text: 'Tampilkan',
				tooltip: BTN_REFERSH_TOOLTIP,
				handler: lap_cat_pers_bbm_search_table,
				iconCls:'icon-refresh'
			}
			,'-' ,{
				text: 'Cetak',
				tooltip: BTN_PRINT_TOOLTIP,
				handler : print_list,
				iconCls:'icon-print',
				
			}]
	});
	/* END GridPanel For Table by Pump */
  	
	
});
</script>
<body style: 'background: url(assets/images/desktop.jpg)'>
<div>
	<div id="el_lap_cat_pers_bbm_filter"></div>
</div>
</body>
</html>